<template>
  <div class="cephalosome">
    <dv-full-screen-container class="contenter">
      <div class="login_frames">
        <!-- 输入框登录  账号-->
        <!-- <div class="login_picture"> -->
        <div class="login_impot">
          <!-- 账号 -->

          <div class="input_go">
            <img src="@/assets/img/login_user.png" style="width: 2rem; height: 2rem" />
            <el-input v-model="form.username" class="login_input" placeholder="请输入用户名" />
          </div>
          <!-- 密码 -->
          <div class="input_go">
            <img src="@/assets/img/login_password.png" style="width: 2rem; height: 2rem" />
            <el-input v-model="form.password" class="login_input" type="password" placeholder="请输入密码" />
          </div>
          <!-- 验证码 -->
          <div class="input_go">
            <img src="@/assets/img/login_password.png" style="width: 2rem; height: 2rem" />
            <el-input v-model="form.captcha" class="srcyzm_input" placeholder="请输入验证码" />
            <img class="srcyzm_img" :src="srcyzm" style="width: 14rem; height: 3rem" @click="showImageCode" />
          </div>
          <!-- 登录 -->
          <div class="login_go" @click="login">
            <div class="login_goer">登录</div>
          </div>
        </div>
        <!-- </div> -->
      </div>
    </dv-full-screen-container>
  </div>
</template>

<script>
import { getUUID } from '@/utils/util'
export default {
  data() {
    return {
      form: {
        username: '',
        password: '',
        captcha: '',
        uuid: ''
      },
      srcyzm: ''
    }
  },
  mounted() {
    this.showImageCode()
  },
  methods: {
    showImageCode() {
      this.form.uuid = getUUID()
      // 显示验证码
      this.srcyzm = '/apiUrl/captcha.jpg?uuid=' + this.form.uuid
    },
    //登录
    login() {
      let loginParams = {}
      loginParams.username = this.form.username
      loginParams.password = this.form.password
      loginParams.captcha = this.form.captcha
      loginParams.uuid = this.form.uuid
      loginParams.isMobile = false
      var alarmdatefrom = new Date() //
      var year = alarmdatefrom.getFullYear() //获取完整的年份(4位,1970-????)
      var month = alarmdatefrom.getMonth() + 1 //获取当前月份(1-12)
      var day = alarmdatefrom.getDate()
      loginParams.realDay = year + '' + month + '' + day
      this.$axios
        .post('/apiUrl/emgy/sys/login', loginParams)
        .then(resData => {
          if (resData.code == 0) {
            this.$message({
              showClose: true,
              message: '登录成功',
              type: 'success'
            })
            sessionStorage.setItem('security_yuyao_token', resData.security_yuyao_token)
            sessionStorage.setItem('intelligenceUrl', resData.intelligenceUrl)
            this.$router.push({
              path: '/largescreen',
              query: {}
            })
            this.$axios.get('/apiUrl/sys/user/info', {}).then(res => {
              sessionStorage.setItem('userInformation', res.user.name)
            })
          } else {
            this.$message({
              showClose: true,
              message: resData.msg,
              type: 'error'
            })
            this.showImageCode()
          }
        })
        .catch(error => {
          console.log(error)
        })
    }
  }
}
</script>

    
<style scoped>
@import '../assets/css/login.css';
</style>